<?php

class Welcome extends CI_Controller {

    function __construct() {
        parent::__construct();
        $this->load->helper(array('form', 'url', 'date'));
        $this->load->library('session');
        $this->load->model("settings/kim_model", "", TRUE);
        $this->load->model("settings/tab_cats_model", "", TRUE);
        $this->load->model("settings/contact_model", "", TRUE);
    }

    function index($newVisit="yes") {
        if ($newVisit === "yes") {
            $this->kim_model->incrementHitCount();
        }
        $data["title"] = "- Home";
        if ($this->session->userdata("admin")) {
            $data["cats"] = $this->tab_cats_model->getAll();
        }
        $this->load->view('templates/header', $data);
        $this->load->view('welcome/welcome');
        $this->load->view('templates/footer');
    }

    function contact() {
        $data["title"] = "- Contact us";
        if ($this->session->userdata("admin")) {
            $data["cats"] = $this->tab_cats_model->getAll();
        }
        $this->load->view('templates/header', $data);
        $this->load->view('welcome/contact');
        $this->load->view('templates/footer');
    }

    function contactSave() {
        $this->contact_model->newMsg();
        echo "Saved, thank you.";
    }

}